package com.samphanie.mbg.mapper.sys;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.samphanie.mbg.model.sys.SysRole;
import com.samphanie.mbg.model.sys.SysUserRole;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 用户角色关联Mapper接口
 *
 * @author zsy
 * @date 2021-05-10
 */
@Mapper
public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {

    List<SysRole> getUserRoleListByUid(@Param("userId") Long userId);

    @Select("        select r.id, r.role_name, r.display_name, r.admin_count, r.show_status, r.built_in, r.sort, r.create_time, r.remark\n" +
            "        from sys_user_role ur\n" +
            "        left join sys_role r on ur.role_id = r.id\n" +
            "        where ur.is_delete = 0 and r.is_delete = 0 and (ur.user_id = #{userId})")
    List<SysRole> queryUserRoleListByUid(@Param("userId") Long userId);
}
